package cn.csc.module.product.dal.mysql.attrcategory;

import cn.csc.framework.common.pojo.PageResult;
import cn.csc.framework.mybatis.core.mapper.BaseMapperX;
import cn.csc.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.csc.module.product.controller.admin.attrcategory.vo.AttrCategoryExportReqVO;
import cn.csc.module.product.controller.admin.attrcategory.vo.AttrCategoryPageReqVO;
import cn.csc.module.product.dal.dataobject.attrcategory.AttrCategoryDO;
import cn.csc.module.product.dal.dataobject.category.CategoryDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.math.BigInteger;
import java.util.List;

/**
 * 属性与分类关联信息 Mapper
 *
 * @author liuchuang
 */
@Mapper
public interface AttrCategoryMapper extends BaseMapperX<AttrCategoryDO> {

    default PageResult<AttrCategoryDO> selectPage(AttrCategoryPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<AttrCategoryDO>()
                .eqIfPresent(AttrCategoryDO::getCategoryId, reqVO.getCategoryId())
                .eqIfPresent(AttrCategoryDO::getAttrId, reqVO.getAttrId())
                .betweenIfPresent(AttrCategoryDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(AttrCategoryDO::getId));
    }

    default List<AttrCategoryDO> selectList(AttrCategoryExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<AttrCategoryDO>()
                .eqIfPresent(AttrCategoryDO::getCategoryId, reqVO.getCategoryId())
                .eqIfPresent(AttrCategoryDO::getAttrId, reqVO.getAttrId())
                .betweenIfPresent(AttrCategoryDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(AttrCategoryDO::getId));
    }



    /**
     * 据属性Id，获取属性关联的分类列表信息
     *
     * @param attrId
     * @return
     */
    List<CategoryDO> listByAttrId(@Param("attrId") BigInteger attrId);




}
